﻿package com.mathMl{
	//import com.Tracer;
	import flash.display.MovieClip;
	import fmath.Style;
	import flash.display.LoaderInfo;
	import fmath.MathML;
	import flash.geom.Rectangle;
	import flash.display.Sprite;
	import flash.events.Event;

	public class MathPanel extends MovieClip
	{
		public var xmlData:XML;
		private var mathML:MathML;
		private var drawPanel:MovieClip = new MovieClip();
		public var style:Style = new Style();
		function MathPanel()
		{
		}
		
		public function drawFormula(mathXML:String, defaultSize:Number)
		{
			style.size = defaultSize + 3;
			style.mathvariant = "normal"//"Arial Unicode Ms";
			style.color = "#000000";
			xmlData = new XML(mathXML);
			//trace(xmlData);
			var mathML:MathML  = new MathML(xmlData, style);
			this.addChild(drawPanel);
			mathML.drawFormula(drawPanel, callbackFunct);
		}
		function callbackFunct(r:Rectangle)
		{
			//trace("callbackFunct:" + r);
			//Tracer.traceMsg("callbackFunct:" + r);
			//drawPanel.x += (0 - r.x);
			//drawPanel.y += (0 - r.y);
			//drawPanel.y = drawPanel.y - r.height / 2;
			//dispatchEvent(new Event(Event.COMPLETE));
			dispatchEvent(new MathPanelEvent(MathPanelEvent.ON_FORMULA_ADDED, true, false));
		}
	}
}